﻿
namespace ICommonLibrary.Json {

    public class JsonString : JsonValue {

        public string Value {
            get {
                return _value;
            }
            set {
                _value = value ?? string.Empty;
            }
        }

        private string _value;

        public JsonString(string value) {
            Value = value;
        }

        public override bool Equals(object other) {
            var s = other as JsonString;
            if (s == null) {
                return false;
            }
            return _value.Equals(s._value);
          }

        public override int GetHashCode() {
            return Value.GetHashCode();
        }

        public override JsonString IsString() {
            return this;
        }

        public override string ToJsonString() {
            return JsonUtil.Encode(_value);
        }

    }
}